package com.fire.arthas.demo.service;

import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author  Mr.Fire
 * @date    2022/7/22
 * @desc    
 */
@Service
public class TestService {


    private static final Map<String,String> cache = new HashMap<>();

    static{
        cache.put("1","zhansan");
        cache.put("2","wanwu");
        cache.put("3","lisi");
    }

    @SneakyThrows
    public void traceMethod1(){
        Thread.sleep(1000L);
        System.out.println("trace method-1 run!");
    }


    @SneakyThrows
    public void traceMethod2(){
        StringBuilder str = new StringBuilder();
        str.append("111");
//        Thread.sleep(2000L);
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        str.append("222");
        System.out.println("trace method-2 run!");
    }

    @SneakyThrows
    public void traceMethod3(){
        Thread.sleep(5000L);
        System.out.println("trace method-3 run!");
        traceMethod4();
    }
    
    
    public void traceMethod4(){
        System.out.println("trace method-4 run!");
    }


    public void montorMethod(int i){
        if(i%5==0){
            throw new RuntimeException();
        }
        System.out.println(i);
    }
}


